﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEngine;

// Token: 0x020002EA RID: 746
public class CommonLib
{
	// Token: 0x06001251 RID: 4689 RVA: 0x00094F24 File Offset: 0x00093124
	public static List<string> GetAssetBundleNameListFromPath(string path, bool subdirCheck = false)
	{
		List<string> result = new List<string>();
		if (!global::AssetBundleCheck.IsSimulation)
		{
			string path2 = global::AssetBundleManager.BaseDownloadingURL + path;
			if (subdirCheck)
			{
				List<string> list = new List<string>();
				global::CommonLib.GetAllFiles(path2, "*.unity3d", list);
				result = (from s in list
				select s.Replace(global::AssetBundleManager.BaseDownloadingURL, string.Empty)).ToList<string>();
			}
			else
			{
				if (!Directory.Exists(path2))
				{
					return result;
				}
				result = (from s in Directory.GetFiles(path2, "*.unity3d")
				select s.Replace(global::AssetBundleManager.BaseDownloadingURL, string.Empty)).ToList<string>();
			}
		}
		return result;
	}

	// Token: 0x06001252 RID: 4690 RVA: 0x00094FDC File Offset: 0x000931DC
	public static void GetAllFiles(string path, string searchPattern, List<string> lst)
	{
		if (!Directory.Exists(path))
		{
			return;
		}
		lst.AddRange(Directory.GetFiles(path, searchPattern));
		string[] directories = Directory.GetDirectories(path);
		for (int i = 0; i < directories.Length; i++)
		{
			global::CommonLib.GetAllFiles(directories[i], searchPattern, lst);
		}
	}

	// Token: 0x06001253 RID: 4691 RVA: 0x00095028 File Offset: 0x00093228
	public static void CopySameNameTransform(Transform trfDst, Transform trfSrc)
	{
		global::FindAssist findAssist = new global::FindAssist();
		findAssist.Initialize(trfDst);
		Dictionary<string, GameObject> dictObjName = findAssist.dictObjName;
		global::FindAssist findAssist2 = new global::FindAssist();
		findAssist2.Initialize(trfSrc);
		Dictionary<string, GameObject> dictObjName2 = findAssist2.dictObjName;
		GameObject gameObject = null;
		foreach (KeyValuePair<string, GameObject> keyValuePair in dictObjName)
		{
			if (dictObjName2.TryGetValue(keyValuePair.Key, out gameObject))
			{
				keyValuePair.Value.transform.localPosition = gameObject.transform.localPosition;
				keyValuePair.Value.transform.localRotation = gameObject.transform.localRotation;
				keyValuePair.Value.transform.localScale = gameObject.transform.localScale;
			}
		}
	}

	// Token: 0x06001254 RID: 4692 RVA: 0x00095110 File Offset: 0x00093310
	public static void CreateUUID()
	{
		string text = Application.dataPath;
		text = Path.GetDirectoryName(text);
		string path = text + "/UserData/save/netUID.dat";
		if (File.Exists(path))
		{
			using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read))
			{
				using (BinaryReader binaryReader = new BinaryReader(fileStream))
				{
					string a = binaryReader.ReadString();
					if (a != string.Empty)
					{
						return;
					}
				}
			}
		}
		string directoryName = Path.GetDirectoryName(path);
		if (!Directory.Exists(directoryName))
		{
			Directory.CreateDirectory(directoryName);
		}
		string value = global::YS_Assist.CreateUUID();
		using (FileStream fileStream2 = new FileStream(path, FileMode.Create, FileAccess.Write))
		{
			using (BinaryWriter binaryWriter = new BinaryWriter(fileStream2))
			{
				binaryWriter.Write(value);
			}
		}
	}

	// Token: 0x06001255 RID: 4693 RVA: 0x00095230 File Offset: 0x00093430
	public static string GetUUID()
	{
		string text = Application.dataPath;
		text = Path.GetDirectoryName(text);
		string path = text + "/UserData/save/netUID.dat";
		if (File.Exists(path))
		{
			using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read))
			{
				using (BinaryReader binaryReader = new BinaryReader(fileStream))
				{
					return binaryReader.ReadString();
				}
			}
		}
		return string.Empty;
	}

	// Token: 0x06001256 RID: 4694 RVA: 0x000952CC File Offset: 0x000934CC
	public static T LoadAsset<T>(string assetBundleName, string assetName, bool clone = false, string manifestName = "") where T : UnityEngine.Object
	{
		if (global::AssetBundleCheck.IsSimulation)
		{
			manifestName = string.Empty;
		}
		if (!global::AssetBundleCheck.IsFile(assetBundleName, assetName))
		{
			string message = "読み込みエラー\r\nassetBundleName：" + assetBundleName + "\tassetName：" + assetName;
			global::Debug.LogWarning(message);
			return (T)((object)null);
		}
		global::AssetBundleLoadAssetOperation assetBundleLoadAssetOperation = global::AssetBundleManager.LoadAsset(assetBundleName, assetName, typeof(T), (!manifestName.IsNullOrEmpty()) ? manifestName : null);
		if (assetBundleLoadAssetOperation.IsEmpty())
		{
			string message2 = "読み込みエラー\r\nassetName：" + assetName;
			global::Debug.LogError(message2);
			return (T)((object)null);
		}
		T t = assetBundleLoadAssetOperation.GetAsset<T>();
		if (null != t && clone)
		{
			T t2 = UnityEngine.Object.Instantiate<T>(t);
			t2.name = t.name;
			t = t2;
		}
		return t;
	}
}
